import { ethers } from 'ethers'

import { getJsonRpcProvider } from './provider'

const getContractWithProvider = (address, abi, provider) => {
  if (!provider) {
    provider = getJsonRpcProvider()
  }
  return new ethers.Contract(address, abi, provider)
}

const getContractWithSigner = (address, abi, signer) => {
  return new ethers.Contract(address, abi, signer)
}

const getContractFactory = (abi, bytecode, signer) => {
  return new ethers.ContractFactory(abi, bytecode, signer)
}

export { getContractWithProvider, getContractWithSigner, getContractFactory }
